package Shangke;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.math.BigInteger;

public class Test {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException {

//        Class<?> package_shangke = Class.forName("package Shangke");
//        Class<?>[] declaredClasses = package_shangke.getDeclaredClasses();
//        Field name = package_shangke.getDeclaredField("name");
//        System.out.println(name);
//        System.out.println(declaredClasses);

        Dog dog = new Dog();
        Class<? extends Dog> aClass = dog.getClass();

        //输出构造方法的修饰符
        Constructor<? extends Dog> declaredConstructor = aClass.getDeclaredConstructor();
        int modifiers = declaredConstructor.getModifiers();
        System.out.println(modifiers);

        //获取构造方法和类中属性的数量
        Field[] dog1 = aClass.getDeclaredFields();
        for (Field f : dog1
        ) {
            System.out.println(dog1.length);
        }

        //获取构造方法
        Constructor<?>[] constructors = aClass.getConstructors();
        for (Constructor c : constructors
        ) {
            System.out.println(c);
        }
    }
}

class ListNode {
    int val;
    ListNode next;

    ListNode() {
    }

    ListNode(int val) {
        this.val = val;
    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}

class Solution {
    public static void main(String[] args) {
        ListNode l1 = new ListNode(1);
        ListNode l2 = new ListNode(1);
        ListNode l3 = new ListNode(2);
        ListNode l4 = new ListNode(3);
        ListNode l5 = new ListNode(3);
        l1.next = l2;
        l2.next = l3;
        l3.next = l4;
        l4.next = l5;
        ListNode listNode = new Solution().deleteDuplicates(l1);
        while (listNode != null) {
            System.out.println(listNode.val);
            listNode = listNode.next;
            System.out.println("hello world");
        }
    }

    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null) return head;
        ListNode pre = head;
        ListNode cur = head.next;
        while (cur != null) {
            if (pre.val == cur.val) {
                pre.next = cur.next;
            } else {
                pre = cur;
            }
            cur = cur.next;
        }
        return head;
    }

}
